<!--
 * @Description: loadash数组常用方法
 * @Author: wanggang
 * @Date: 2019-12-28 10:32:09
 -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./lodash.js"></script>
</head>
<body>
    
</body>
<script>

/**
 * @description: _.chunk(array,[size=1]) 将数组拆分成多个size长度的区块,并将这些区块组成一个新数组,如果array无法被分割，剩余元素在一个区块内
 * 
 */
console.log(_.chunk(['a','b','c','d'],2));
console.log(_.chunk(['a','b','c','d'],3));


/**
 * @description: compact(array) 创建新数组,包含原数组的非假元素,false,null,0,"",undefined,NaN
 * 
 */
console.log(_.compact([0,1,false,2,'',3]));

/**
 * @description: _.difference(array,[values]) 排除数组中不在指定数组的值,暂时不支持对象
 */
 console.log(_.difference([1,2,3,4],[1,2]))
 console.log(_.difference([{
    name: 'xiaowang',
    age: 20
 },{
    name: 'xaioli',
    age: 18
 }],[{
     name: 'xiaowang',
     age: 20
 },{
    name: 'xaioli',
    age: 18
 }]))

/**
 * @description: _.differenceBy(检查的数组,排除的值,迭代器) 迭代器先调用，将返回的值做比较
 */
console.log(_.differenceBy([3.1,2.2,1.3],[4.4,2.5],Math.floor));

console.log(_.differenceBy([{
    name:'xiaowang',
    age: 19,
},{
    name: 'xiaoli',
    age: 18
}],[{
    name:'xiaoli',
    age: 18
}]))

</script>
</html>